package predicate

type Table struct {
	Entity any
	Alias  string
}

func (t Table) tableReference() {}
func (t Table) alias()          {}

func (t Table) As(alias string) Table {
	return Table{Entity: t.Entity,
		Alias: alias}
}

// 使用JoinBuilder原因： join语句到这还没构建完成，还需要有on||using才完整

func (t Table) Join(other TableReference) JoinBuilder {
	return JoinBuilder{
		left:  t,
		right: other,
		op:    joinOp,
	}
}

func (t Table) LeftJoin(other TableReference) JoinBuilder {
	return JoinBuilder{
		left:  t,
		right: other,
		op:    leftJoinOp,
	}
}

func (t Table) RightJoin(other TableReference) JoinBuilder {
	return JoinBuilder{
		left:  t,
		right: other,
		op:    rightJoinOp,
	}
}

func (t Table) C(columnName string) Column {
	return Column{
		ColumnName: columnName,
		Entity:     t,
	}
}

func TableOf(entity any) Table {
	return Table{Entity: entity}
}

var _ TableReference = Table{}
var _ Alias = Table{}
